const KerwinToken = artifacts.require('KerwinToken.sol')
const exchange = artifacts.require('Exchange.sol')
const ETHER_ADDRESS="0x0000000000000000000000000000000000000000"
const fromWei =(bn)=>{
    return web3.utils.fromWei(bn, 'ether');
}
const toWei = (number)=>{
    return web3.utils.toWei(number.toString(), 'ether');
}
module.exports = async function(callback) {
    const Kerwintoken = await KerwinToken.deployed()
    const Exchanges = await exchange.deployed()
    const accounts = await web3.eth.getAccounts()//获取所有账号，模拟的10个账号
    console.log('Accounts:', accounts[0]);
    await Exchanges.depositEther({
        from:accounts[0],
        value:toWei(10)
    })
    //必须先授权
    await Kerwintoken.approve(exchange.address, toWei(100000),{from:accounts[0]})
    //交易所转账比特币
    let res = await Exchanges.tokens(ETHER_ADDRESS,accounts[0])
    console.log("增加->交易所->以太币余额：",fromWei(res))

    //交易所转账其他币种
    await Exchanges.depositToken(Kerwintoken.address,toWei(10000),{from:accounts[0]})
    let res1 = await Exchanges.tokens(Kerwintoken.address,accounts[0])
    console.log("增加->交易所->KWT币余额：",fromWei(res1))
    callback()
}